package com.example.bess.pringboot013.shardingsphere.demo.controller;

import com.example.bess.pringboot013.shardingsphere.demo.mapper.UserMapper;
import com.example.bess.pringboot013.shardingsphere.demo.model.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TestController {

    private static final Logger log = LoggerFactory.getLogger(TestController.class);

    @Autowired
    @Qualifier(value = "userMapper")
    private UserMapper userMapper;

    @GetMapping(value = "/")
    public String test() {
        return "SUCCESS";
    }

    @GetMapping(value = "/user/{id}")
    public List<User> selectAll(@PathVariable int id) {
        User user = new User();
        user.setId(id);
        return userMapper.selectUserList1(user);
    }

}
